﻿// DataProductListCtrl.cpp: 实现文件
//

#include "stdafx.h"
#include "zChecker.h"
#include "DataProductListCtrl.h"


// CDataProductListCtrl

IMPLEMENT_DYNAMIC(CDataProductListCtrl, CListCtrl)

CDataProductListCtrl::CDataProductListCtrl()
{

}

CDataProductListCtrl::~CDataProductListCtrl()
{
}


BEGIN_MESSAGE_MAP(CDataProductListCtrl, CListCtrl)
	ON_WM_CREATE()
END_MESSAGE_MAP()



// CDataProductListCtrl 消息处理程序

int CDataProductListCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CListCtrl::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  在此添加您专用的创建代码

	return 0;
}

void CDataProductListCtrl::AttachBitmap()
{
	CBitmap bmp;
	if (bmp.LoadBitmap(IDB_BITMAP_DATA_PRODUCT_LIST_32))
	{
		m_il.Create(32, 32, ILC_COLOR32 | ILC_MASK, 0, 0);
		m_il.Add(&bmp, RGB(255, 0, 255));
		int nCount = m_il.GetImageCount();
		for (int i = 1; i < nCount; i++)         //support 16
		{
			m_il.SetOverlayImage(i, i);
		}
		SetImageList(&m_il, TVSIL_NORMAL);
	}
}

void CDataProductListCtrl::Populate()
{
	ck::DataProductInfo* pProduct = NULL;
	ck::DataProductManager* pManager = ck::DataProductManager::GetInstance();

	DeleteAllItems();
	z_uint32 nCount = pManager->GetCount();
	for (z_uint32 i = 0; i < nCount; i++)
	{
		pProduct = pManager->GetDataProduct(i);
		int nItem = this->InsertItem(i, pProduct->GetName(), i);
		this->SetItemData(nItem, pProduct->GetID());

	}
}